package ProctoH

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
)

func main() {
	//1、连接grpc服务
	grpcConn, err := grpc.Dial("127.0.0.1:8082", grpc.WithInsecure()) //以安全的方式运行
	if err != nil {
		fmt.Println("grpc.dial...失败", err)
	}
	defer grpcConn.Close()

	//2、初始化grpc客户端
	grpcClient := NewResultClient(grpcConn)

	//3、创建并初始化Person对象
	var person Person
	person.Name = "打盹"
	person.Age = 19

	//4、调用远程服务,context.TODO()空对象，占位
	p, err := grpcClient.Say(context.TODO(), &person)
	if err != nil {
		fmt.Println("远程服务调用失败...", err)
	}
	fmt.Println(p)
}
